cmake_minimum_required(VERSION 3.16)

if(WIN32)
    set(CMAKE_TOOLCHAIN_FILE D:/vcpkg/scripts/buildsystems/vcpkg.cmake)
    add_compile_options(/utf-8)
endif(WIN32)

project(qwidget_demo)

set(CMAKE_CXX_STANDARD 17)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(QT_VERSION_MAJOR "5")
find_package(Qt5 COMPONENTS
    Widgets)

if(!Qt6_FOUND)
    find_package(Qt5 REQUIRED COMPONENTS
        Widgets)
    set(QT_VERSION_MAJOR "6")
endif(!Qt6_FOUND)

add_executable(qwidget_demo main.cpp widget.cpp)

target_link_libraries(qwidget_demo
    Qt${QT_VERSION_MAJOR}::Widgets)